package com.zxl.designpattern.behavioral.command;

/**
 * 电灯打开命令
 * 实现Command接口，负责打开电灯
 */
public class LightOnCommand implements Command {

    // 持有电灯对象的引用
    private final Light light;

    /**
     * 构造函数，初始化电灯对象
     * @param light 电灯对象
     */
    public LightOnCommand(Light light) {
        this.light = light;
    }

    @Override
    public void execute() {
        light.on();
    }

    @Override
    public void undo() {
        light.off();
    }

    @Override
    public String getCommandName() {
        return "开灯";
    }
}    